package com.itheima.exerciseTest.test60_69;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

public class Test65 {
    public static void main(String[] args) throws InterruptedException {
        // 创建ConcurrentHashMap集合对象
        HashMap<Integer,Integer> hm = new HashMap<>();

        // 创建线程
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 50; i++) {
                hm.put(i,i);
            }
        });

        Thread t2 = new Thread(() -> {
            for (int i = 50; i <= 100; i++) {
                hm.put(i, i);
            }
        });
        t1.start();
        t2.start();

        Thread.sleep(1);
        for (int i = 0; i < 101; i++) {
            Integer value = hm.get(i);
            System.out.println(value);
        }
        // System.out.println(hm);
    }
}
